﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Web;

namespace Stamp_For_Africa_Version_2.Models
{
  public partial class Colour
  {
    public bool IsValid
    {
      get { return (GetRuleViolations().Count() == 0); }
    }

    public IEnumerable<RuleViolation> GetRuleViolations()
    {
      if (String.IsNullOrEmpty(Colour1))
        yield return new RuleViolation("Colour name required", "Colour");

      yield break;
    }

    partial void OnValidate(ChangeAction action)
    {
      if (!IsValid)
        throw new ApplicationException("Rule violations prevent saving");
    }

		public override string ToString()
		{
			return Colour1;
		}
  }
}